<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.10/dist/vue.min.js"></script>
</head>

<body>
    <div id="app">
        <input @keydown.capslock="tip" type="text">
        <h2 v-if="pd">{{msg}}</h2>
    </div>
</body>
<script>
    Vue.config.productionTip = false
    Vue.config.keyCodes.capslock = 20
    var vue = new Vue({
        el: "#app",
        data: {
            msg: '当前以切换大写模式',
            pd: false
        },
        methods: {
            tip() {
                this.pd = !this.pd
            }
        }
    })
</script>

</html>